﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebComponents.Data;
using WebComponents;
using System.Collections.Generic;

public partial class _Default : System.Web.UI.Page {
  public string str = "";
  protected void Page_Load(object sender, EventArgs e) {
    PageDescriptionInfo pageDesctiption = PageDescriptionController.GetByPageName("GioiThieuNgan", Global.CurrentCultureCode);
    if (pageDesctiption != null) {
      lblGioiThieu.Text = pageDesctiption.FullDescription;
    }
    var list = ProductController.List().Where(p => p.StatusID == 0).Skip(0).Take(12);
    if (list.Count() > 0) {
      int i = 0;
      int index = 0;
      foreach (ProductInfo p in list) {
        i++;
        if (i == 1) {
          str += "<div class='rows_product'>";
          str += "<div class='col_1_2'>";
          str += "  <div class='col_1'>";
          str += "      <div class='frame_product'>";
          str += string.Format("           <a href=\"{0}chi-tiet-san-pham/{1}/{2}/{3}-.aspx\">", Page.ResolveClientUrl("~/"), p.CateID, p.ProductID, ConvertType.StripDiacritics(p.ProductName));
          str += string.Format("                    <img src='{0}' alt='{1}' title='{1}' class='pic_product'></a></div>", p.SmallImageUrl, p.ProductName);
          str += "            <p>";
          str += "               <img src='images/shadow_product.jpg' alt=''></p>";
          str += string.Format("    <p> <a href='{0}chi-tiet-san-pham/{1}/{2}/{3}-.aspx' title='{3}' class='link_title_product'>{3}</a></p>", Page.ResolveClientUrl("~/"), p.CateID, p.ProductID, ConvertType.StripDiacritics(p.ProductName));
          str += "       <p class='space_price'>";
          str += string.Format("         <span class='txt_price01'>Giá bán: </span><span class='txt_price02'>{0} VNĐ</span></p>", p.UnitPrice.ToString("###,###,###"));
          str += "  </div>";
          if (index == list.Count() - 1) {
            str += "  </div></div>";
          }
        } else if (i == 2) {
          str += "  <div class='col_2'>";
          str += "      <div class='frame_product'>";
          str += string.Format("           <a href=\"{0}chi-tiet-san-pham/{1}/{2}/{3}-.aspx\">", Page.ResolveClientUrl("~/"), p.CateID, p.ProductID, ConvertType.StripDiacritics(p.ProductName));
          str += string.Format("                    <img src='{0}' alt='{1}' title='{1}' class='pic_product'></a></div>", p.SmallImageUrl, p.ProductName);
          str += "            <p>";
          str += "               <img src='images/shadow_product.jpg' alt=''></p>";
          str += string.Format("    <p> <a href='{0}chi-tiet-san-pham/{1}/{2}/{3}-.aspx' title='{3}' class='link_title_product'>{3}</a></p>", Page.ResolveClientUrl("~/"), p.CateID, p.ProductID, ConvertType.StripDiacritics(p.ProductName));
          str += "       <p class='space_price'>";
          str += string.Format("         <span class='txt_price01'>Giá bán: </span><span class='txt_price02'>{0} VNĐ</span></p>", p.UnitPrice.ToString("###,###,###"));
          str += "  </div></div>";
        } else if (i == 3) {
          str += " <div class='col_3'>  <div class='col_1'>";
          str += "      <div class='frame_product'>";
          str += string.Format("           <a href=\"{0}chi-tiet-san-pham/{1}/{2}/{3}-.aspx\">", Page.ResolveClientUrl("~/"), p.CateID, p.ProductID, ConvertType.StripDiacritics(p.ProductName));
          str += string.Format("                    <img src='{0}' alt='{1}' title='{1}' class='pic_product'></a></div>", p.SmallImageUrl, p.ProductName);
          str += "            <p>";
          str += "               <img src='images/shadow_product.jpg' alt=''></p>";
          str += string.Format("    <p> <a href='{0}chi-tiet-san-pham/{1}/{2}/{3}-.aspx' title='{3}' class='link_title_product'>{3}</a></p>", Page.ResolveClientUrl("~/"), p.CateID, p.ProductID, ConvertType.StripDiacritics(p.ProductName));
          str += "       <p class='space_price'>";
          str += string.Format("         <span class='txt_price01'>Giá bán: </span><span class='txt_price02'>{0} VNĐ</span></p>", p.UnitPrice.ToString("###,###,###"));
          str += "  </div></div></div>";
          i = 0;
        }
        index++;
      }
    }
    var listtb = ProductController.List().Where(p => p.StatusID == 1).Skip(0).Take(20);
    List<ProductInfo> list1 = new List<ProductInfo>();
    List<ProductInfo> list2 = new List<ProductInfo>();
    if (listtb.Count() > 10)
      list1 = listtb.Skip(0).Take(10).ToList();
    else
      list1 = listtb.ToList();
    if (listtb.Count() > 10)
      list2 = listtb.Skip(10).Take(listtb.Count()).ToList();
    rptTieuBieu1.DataSource = list1;
    rptTieuBieu1.DataBind();
    rptTieuBieu2.DataSource = list2;
    rptTieuBieu2.DataBind();
  }
}
